package zuoye722;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map.Entry;

public class demo8 {
   public static void main(String[] args) {
			//准备牌
			ArrayList<String> poker=new ArrayList<String>();
			String[] colors={"♠","♣","♦","♥"};
			String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
			poker.add("大王");
			poker.add("小王");	
			for(String number:numbers){
				for(String color:colors){
					poker.add(color+number);
				}
			}
			System.out.println(poker);
			//洗牌
			/*Collections.shuffle(poker);*/
			/*System.out.println(poker);*/
			
			Player p1=new Player();p1.setName("老王");
			Player p2=new Player();p2.setName("老李");
			Player p3=new Player();p3.setName("老六");
			ArrayList<String> dipai=new ArrayList<String>();
			//摸牌
		/*	for(int i=0;i<poker.size();i++){
				//获取每一张的牌
				String p = poker.get(i);
				if(i>=51){
					dipai.add(p);
				}else if(i%3==0){
					p1.getPoker().add(p);
				}else if(i%3==1){
					p2.getPoker().add(p);
				}else if(i%3==2){
					p3.getPoker().add(p);
				}
			}*/
			
			
			LinkedHashMap<Integer,String> map=new LinkedHashMap<>();
			ArrayList<Integer> listnum=new ArrayList<>();
			for(int i=54;i>=1;i--){
				listnum.add(i);
			}
		    for(int i=0;i<poker.size();i++){
		    map.put(listnum.get(i),poker.get(i));
		    }
		    
		//洗牌	
		    Collections.shuffle(listnum);
		    ArrayList<Integer> list1=new ArrayList<>(17);
		    ArrayList<Integer> list2=new ArrayList<>(17);
		    ArrayList<Integer> list3=new ArrayList<>(17);
		    for(int i=0;i<listnum.size();i++){
				//获取每一张的牌
				String p = map.get(listnum.get(i));
				if(i>=51){
					dipai.add(p);
				}else if(i%3==0){
					list1.add(listnum.get(i));
				}else if(i%3==1){
					list2.add(listnum.get(i));
				}else if(i%3==2){
					list3.add(listnum.get(i));
				}
				
			}
		    
		    Collections.sort(list1);
		    Collections.sort(list2);
		    Collections.sort(list3);
		    
		   
		    
		    for(int i:list1){
		    	p1.getPoker().add(map.get(i));
				
		    }
		    for(int i:list2){
		    	p2.getPoker().add(map.get(i));
		    }
		    
		    for(int i:list3){
		    	p3.getPoker().add(map.get(i));
				
		    }
		    
			//看牌
			System.out.println(p1.getName()+"的牌:"+p1.getPoker());
			System.out.println(p2.getName()+"的牌:"+p2.getPoker());
			System.out.println(p3.getName()+"的牌:"+p3.getPoker());
			System.out.println("底牌:"+dipai);
	        
			
			
}
  
}